<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<script type="text/javascript">

function add(lbox, rbox) {
     var arrRbox = new Array();
     var arrLookup = new Array();
     var arrAlready = new Array();
     var i;
     for(i=0; i<lbox.options.length; i++) {
          arrLookup[lbox.options[i].text] = lbox.options[i].value;
          arrAlready[lbox.options[i].text] = 0;
     }
     for(i=0; i<rbox.options.length; i++) {
          arrLookup[rbox.options[i].text] = rbox.options[i].value;
	  arrAlready[rbox.options[i].text] = rbox.options[i].value;
	  arrRbox[i] = rbox.options[i].text;
     }
     var rLength = arrRbox.length;
     for(i=0; i<lbox.options.length; i++) {
          if(lbox.options[i].selected && lbox.options[i].value != "" && arrAlready[lbox.options[i].text] == 0) {
               arrRbox[rLength] = lbox.options[i].text;
               rLength++;
          }
     }
     arrRbox.sort();
     rbox.length = 0;
     var c;
     for(c=0; c<arrRbox.length; c++) {
     	var no = new Option();
     	no.value = arrLookup[arrRbox[c]];
     	no.text = arrRbox[c];
     	rbox[c] = no;
     }
}

function remove(lbox, rbox) {
     var arrRbox = new Array();
     var arrLookup = new Array();
     var i;
     var rLength = 0;
     for(i=0; i<rbox.options.length; i++) {
          arrLookup[rbox.options[i].text] = rbox.options[i].value;
          if(!rbox.options[i].selected && rbox.options[i].value != "") {
               arrRbox[rLength] = rbox.options[i].text;
               rLength++;
          }
     }
     arrRbox.sort();
     rbox.length = 0;
     var c;
     for(c=0; c<arrRbox.length; c++) {
     	var no = new Option();
     	no.value = arrLookup[arrRbox[c]];
     	no.text = arrRbox[c];
     	rbox[c] = no;
     }
}

// PickList II script (aka Menu Swapper)- By Phil Webb (http://www.philwebb.com)
// Visit JavaScript Kit (http://www.javascriptkit.com) for this JavaScript and 100s more
// Please keep this notice intact

function move(fbox, tbox) {
     var arrFbox = new Array();
     var arrTbox = new Array();
     var arrLookup = new Array();
     var i;
     for(i=0; i<tbox.options.length; i++) {
          arrLookup[tbox.options[i].text] = tbox.options[i].value;
          arrTbox[i] = tbox.options[i].text;
     }
     var fLength = 0;
     var tLength = arrTbox.length
     for(i=0; i<fbox.options.length; i++) {
          arrLookup[fbox.options[i].text] = fbox.options[i].value;
          if(fbox.options[i].selected && fbox.options[i].value != "") {
               arrTbox[tLength] = fbox.options[i].text;
               tLength++;
          } else {
               arrFbox[fLength] = fbox.options[i].text;
               fLength++;
          }
     }
     arrFbox.sort();
     arrTbox.sort();
     fbox.length = 0;
     tbox.length = 0;
     var c;
     for(c=0; c<arrFbox.length; c++) {
          var no = new Option();
          no.value = arrLookup[arrFbox[c]];
          no.text = arrFbox[c];
          fbox[c] = no;
     }
     for(c=0; c<arrTbox.length; c++) {
     	var no = new Option();
     	no.value = arrLookup[arrTbox[c]];
     	no.text = arrTbox[c];
     	tbox[c] = no;
     }
}

function selectAll(box) {
     for(var i=0; i<box.length; i++) {
     box[i].selected = true;
     }
}
</script>
